package com.feige.controller;


import com.feige.pojo.vo.ChatMsgVo;
import com.feige.result.AjaxResult;
import com.feige.service.PrivateChatMsgService;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 私聊消息表 前端控制器
 * </p>
 *
 * @author feige
 * @since 2020-12-26
 */
@Api(tags = "私聊消息表 前端控制器")
@RestController
@RequestMapping("/chat/private-chat-msg")
public class PrivateChatMsgController {
    @Resource
    private PrivateChatMsgService privateChatMsgService;


    @GetMapping("/get/{pageNum}")
    public AjaxResult queryChatMsg(@PathVariable Integer pageNum, String senderId, String receiverId, Long id){
        List<ChatMsgVo> chatMsgVos = privateChatMsgService.queryChatMsg(pageNum, senderId, receiverId,id);
        int total = privateChatMsgService.queryChatMsgTotal(senderId,receiverId,id);
        AjaxResult success = AjaxResult.success(chatMsgVos);
        success.put("total",total);
        return success;
    }

    @GetMapping("/get/unsigned/{receiverId}")
    public AjaxResult queryUnsignedMsg(@PathVariable String receiverId){
        List<ChatMsgVo> chatMsgVos = privateChatMsgService.queryUnsignMsg(receiverId);
        return AjaxResult.success(chatMsgVos);
    }


}

